package com.work.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Date:2025-06-09
 * Time:22:25
 */
@Order(24)
@Slf4j
@Component
@Aspect
public class AspectDemo {
    @Pointcut("execution(* com.work.aop.controller..*(..))")//切点
   // @Pointcut("execution(* com.work.aop.controller.*.*(..))")//切点
    public void pt(){}

    @Before("pt()")
    public void doBefore(){
        log.info("AspectDemo do before....");
    }

    @After("pt()")
    public void doAfter(){
        log.info("AspectDemo do after....");
    }

    @Around("pt()")//必须要有返回值
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("AspectDemo do aroundBefore....");
        Object proceed = joinPoint.proceed();
        log.info("AspectDemo do aroundAfter....");
        return proceed;
    }

    @AfterReturning("pt()")
    public void doAfterReturning(){
        log.info("AspectDemo do afterReturning....");
    }

    @AfterThrowing("pt()")
    public void doAfterThrowing(){
        log.info("AspectDemo do afterThrowing....");
    }
}
